package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.Filter.RequestParameterWrapper;
import com.wuseguang.springcloud.service.StudentEvaluationScoreRecordService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 学生评价分数记录 表 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-04-22
 */
@RestController
@RequestMapping("/studentEvaluationScoreRecord")
public class StudentEvaluationScoreRecordController {



    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private StudentEvaluationScoreRecordService studentEvaluationScoreRecordServiceImpl;


    /**
     * 查询班级表现
     * @param request
     * @param classId 班级id
     * @param type 0 是查询全部教师，1只查看自己的。默认0
     * @param findType 0本周,1上周,2本月,3自定义。默认0
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return
     */
    @RequestMapping("/findClassPerformance")
    public Result findClassPerformance(RequestParameterWrapper request,
                                       @RequestParam(value = "classId") Integer classId,
                                       @RequestParam(value = "type", required = false,defaultValue = "0") Integer type,
                                       @RequestParam(value = "findType", required = false,defaultValue = "0") Integer findType,
                                       @RequestParam(value = "startTime", required = false) String startTime,
                                       @RequestParam(value = "endTime", required = false) String endTime){

        logger.info("查询班级表现 classId={}",classId);
        String teacherId = request.getParam("teacherId");
        return studentEvaluationScoreRecordServiceImpl.findClassPerformance(classId,teacherId,type,findType,startTime,endTime);
    }

    /**
     * 删除表现评分
     * @param request
     * @param id 学生评价分数记录id
     * @return
     */
    @RequestMapping("/deltePerformanceScore")
    public Result deltePerformanceScore(RequestParameterWrapper request,
                                        @RequestParam(value = "id") Integer id){
        logger.info("删除表现评分 学生评价分数记录id={}",id);
        return studentEvaluationScoreRecordServiceImpl.deltePerformanceScore(id);
    }

    /**
     * 查询个人表现
     * @param request
     * @param studentId 学生id
     * @param findType 0本周,1上周,2本月,3自定义
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return
     */
    @RequestMapping("/findPersonalPerformance")
    public Result findPersonalPerformance(RequestParameterWrapper request,
                                          @RequestParam(value = "studentId", required = false) Integer studentId,
                                          @RequestParam(value = "findType", required = false,defaultValue = "0") Integer findType,
                                          @RequestParam(value = "startTime", required = false) String startTime,
                                          @RequestParam(value = "endTime", required = false) String endTime){
        logger.info("查询个人表现,studentId={}",studentId);
        return studentEvaluationScoreRecordServiceImpl.findPersonalPerformance(studentId,findType,startTime,endTime);
    }

    /**
     * 删除文字点评
     * @param request
     * @param id 文字点评id
     * @return
     */
    @RequestMapping("/deleteTextEvaluation")
    public Result deleteTextEvaluation(RequestParameterWrapper request,
                                       @RequestParam(value = "id", required = false) Integer id){
        logger.info("删除文字点评");
        return studentEvaluationScoreRecordServiceImpl.deleteTextEvaluation(id);
    }

    /**
     * 查询教师评分统计
     * @param request
     * @param teacherId 教师id
     * @param findType 0本周,1上周,2本月,3自定义
     * @param startTime 开始时间
     * @param endTime 结束时间
     * @return
     */
    @RequestMapping("/findTeacherScoringStatistics")
    public Result findTeacherScoringStatistics(RequestParameterWrapper request,
                                               @RequestParam(value = "teacherId", required = false) Integer teacherId,
                                               @RequestParam(value = "findType", required = false,defaultValue = "0") Integer findType,
                                               @RequestParam(value = "startTime", required = false) String startTime,
                                               @RequestParam(value = "endTime", required = false) String endTime){
        logger.info("查询教师评分统计");
        //获取学校id
        String schoolId = request.getParam("schoolId");
        return studentEvaluationScoreRecordServiceImpl.findTeacherScoringStatistics(schoolId,teacherId,findType,startTime,endTime);
    }
}

